<?php

namespace App\Http\Controllers;

use App\Comment;
use \App\Post;

class CommentController extends Controller
{
    public function store(Post $post){
        $this->validate(\request(),[
            'body'=>'required|min:5'
        ]);

        $post->addComment(new Comment([
            'user_id'=>auth()->user()->id,
            'body' => \request('body'),
        ]));

        return back();
    }
}
